package cn.com.generaldata.os.service.indicator_evaluation.composition_analysis;

import org.apache.commons.lang3.Validate;

import cn.com.generaldata.jsme_indicator_system.entity.IndicatorEvaluation;
import cn.com.generaldata.os.service.indicator_constant.ProvinceIndicatorConstant;
import cn.com.generaldata.os.service.indicator_evaluation.IndicatorEvaluationCalculateService;
import cn.com.generaldata.os.vo.IndicatorAccountVO;

/**
 * 海洋盐业增加值占主要海洋产业增加值比重评估指标计算类.
 */
public class SaltIncreasetoGOPCalculateService extends IndicatorEvaluationCalculateService {

	private String majorMarineIndustryAddvalueIndicatorName = ProvinceIndicatorConstant.MAJOR_MARINE_ADDVALUE_NAME;

	@Override
	protected Double calculate(IndicatorEvaluation indicator, IndicatorAccountVO indicatorAccountVO) {
		Double currentBase = getBaseIndicatorVal(indicatorAccountVO, indicatorAccountVO.getYear());
		Double currentParent = getAddValueOfSalt(indicatorAccountVO, indicatorAccountVO.getYear());

		return (currentParent / currentBase) * 100;
	}

	private Double getAddValueOfSalt(IndicatorAccountVO indicatorAccountVO, int year) {
		Double result = getInputOrAccountingIndicatorValue(indicatorAccountVO, year,
				ProvinceIndicatorConstant.SALT_ADDVALUE_NAME);
		Validate.isTrue(result != null);
		return result;
	}

	private Double getBaseIndicatorVal(IndicatorAccountVO indicatorAccountVO, int year) {
		Double result = getInputOrAccountingIndicatorValue(indicatorAccountVO, year,
				majorMarineIndustryAddvalueIndicatorName);
		Validate.isTrue(result != null);
		return result;
	}

}
